// i.d(t, { N: () => DataSyncStore })

import { NotImplementedError, ReadOnlyError } from "../exception/store.exception"
import { DataSync } from "./DataSync"

export default class DataSyncStore<T = any> {
  sync: DataSync
  config: any
  constructor(e: DataSync, t: any) {
    this.sync = e
    this.config = t
  }
  async read() {
    const i = await this.sync.load()
    return i as T
  }
  addMonitor(e) {
    if (this.config.readonly) throw new ReadOnlyError("Datasync is in read-only")
    this.sync.addMonitor(e)
  }
  async revert() {
    return this.sync.reset()
  }
  async create() {
    throw new NotImplementedError()
  }
  async update() {
    throw new NotImplementedError()
  }
  async delete() {
    throw new NotImplementedError()
  }
  async refresh() {
    throw new NotImplementedError()
  }
}
